home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00001_startMovie.ls next >
Encoding:
Text File  |  1996-07-17  |  3.9 KB  |  127 lines

  1. global gCPU, gFlushObject, gPoint, gIOerrors, gXobjPath, gFileIOobject, gMiscXobject, gSavePath, gRearWindowObject, gInitObject, gCopyObj, gFixpal, gCDpath, gFileSep
  2.  
  3. on startMovie
  4.   set the mouseDownScript to "dontPassEvent"
  5.   clearAllActors()
  6.   if gCPU = #Mac then
  7.     activateRearWindow()
  8.     openXLib(gXobjPath & "Misc_X XObj")
  9.     set gMiscXobject to Misc_X(mnew)
  10.     set gSavePath to gMiscXobject(mSystemFolder) & "Preferences:Road Construction" & gFileSep
  11.     openXLib(gXobjPath & "StageToCast XObj")
  12.     openXLib(gXobjPath & "FixPalette XObj")
  13.     set gFixpal to FixPalette(mnew, the stageLeft, the stageTop, the stageRight, the stageTop)
  14.     openXLib(gXobjPath & "Johnny XObj")
  15.     set gFlushObject to Johnny(mnew)
  16.   else
  17.     openXLib(gXobjPath & "misc_x.dll")
  18.     set gMiscXobject to Misc_X(mnew)
  19.     set gSavePath to gMiscXobject(mWindowsDirectory) & "RCAGAMES" & gFileSep
  20.     openXLib(gXobjPath & "xobjdll.dll")
  21.     openXLib(gXobjPath & "eventq.dll")
  22.     openXLib(gXobjPath & "fileio.dll")
  23.     set gFlushObject to eventq(mnew)
  24.   end if
  25.   if gMiscXobject(mFolderExists, gSavePath) = 0 then
  26.     set theResult to gMiscXobject(mInsureFolder, gSavePath & gFileSep)
  27.     if theResult <> 0 then
  28.       alert("Problem creating Road Construction folder as" && gSavePath)
  29.     end if
  30.   end if
  31.   if objectp(gMiscXobject) then
  32.     gMiscXobject(mdispose)
  33.   end if
  34.   set filePath to gSavePath & "PREFS"
  35.   set readObject to FileIO(mnew, "read", filePath)
  36.   if not objectp(readObject) then
  37.     set prefsString to "1,1,1"
  38.     set writeObject to FileIO(mnew, "write", filePath)
  39.     writeObject(mWriteString, prefsString)
  40.     writeObject(mdispose)
  41.   else
  42.     readObject(mdispose)
  43.   end if
  44.   set gIOerrors to [33: "File directory full", 34: "Volume full", 35: "Volume not found", 36: "I/O Error", 37: "Bad file name", 38: "File not open", 42: "Too many files open", 43: "File not found", 49: "File open with write permission", 56: "No such drive", 65: "No disk in drive", 120: "Directory not found"]
  45.   set gPoint to the number of cast "point"
  46. end
  47.  
  48. on keyDownHandler
  49.   if the commandDown then
  50.     if (the key = "w") or (the key = "q") or (the key = ".") then
  51.       cleanUpXobjects()
  52.       quit()
  53.     end if
  54.   end if
  55. end
  56.  
  57. on cleanUpXobjects
  58.   if objectp(gFlushObject) then
  59.     gFlushObject(mdispose)
  60.   end if
  61.   if objectp(gMiscXobject) then
  62.     gMiscXobject(mdispose)
  63.   end if
  64.   if objectp(gPrinterObject) then
  65.     gPrinterObject(mdispose)
  66.   end if
  67.   if objectp(gFixpal) then
  68.     gFixpal(mdispose)
  69.   end if
  70.   if objectp(gCopyObj) then
  71.     gCopyObj(mdispose)
  72.   end if
  73.   if gCPU = #Mac then
  74.     if objectp(gRearWindowObject) then
  75.       gRearWindowObject(mdispose)
  76.     end if
  77.   end if
  78.   closeXLib()
  79. end
  80.  
  81. on stopMovie
  82.   set the trace to 0
  83.   cleanUpXobjects()
  84. end
  85.  
  86. on activateRearWindow
  87.   if factory("RearWindow") = 0 then
  88.     openXLib(gXobjPath & "RearWindow XObj")
  89.   end if
  90.   if objectp(gRearWindowObject) then
  91.     gRearWindowObject(mdispose)
  92.   end if
  93.   makeObjIfNeeded()
  94.   gRearWindowObject(mPatToWindow, -5)
  95. end
  96.  
  97. on showObjectProps object
  98.   put "properties :"
  99.   repeat with x = 1 to count(object)
  100.     set propName to getPropAt(object, x)
  101.     put propName && getProp(object, propName)
  102.   end repeat
  103.   put RETURN & "------"
  104. end
  105.  
  106. on makeObjIfNeeded
  107.   if not objectp(gRearWindowObject) then
  108.     set gRearWindowObject to RearWindow(mnew, "M")
  109.     if value(gRearWindowObject) < 0 then
  110.       alert("System error" && gRearWindowObject && "trying to create the RearWindow object in RAM (multiple-monitor config).")
  111.       stopMovie()
  112.       exit
  113.     end if
  114.     if the freeBlock < gRearWindowObject(mGetMemoryNeeded) then
  115.       if objectp(gRearWindowObject) then
  116.         gRearWindowObject(mdispose)
  117.         set gRearWindowObject to RearWindow(mnew, "S")
  118.       end if
  119.       if value(gRearWindowObject) < 0 then
  120.         alert("System error" && gRearWindowObject && "trying to create the RearWindow object in RAM (single-monitor config).")
  121.         stopMovie()
  122.         exit
  123.       end if
  124.     end if
  125.   end if
  126. end
  127.